#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include "test_general.h"


//Basic:
bool test_threads_func_uthread_join_1();
bool test_threads_func_uthread_join_2();
bool test_threads_func_uthread_create();
bool test_threads_func_uthread_exit();
bool test_threads_func_uthread_cancel();
bool test_threads_func_uthread_yield();

bool test_mutex_func_uthread_mutex_destroy();
bool test_mutex_func_uthread_mutex_lock();
bool test_mutex_func_uthread_mutex_try_lock();
bool test_mutex_func_uthread_mutex_unlock();

bool test_io_func_uthread_open();
bool test_io_pipes_1();


//Others:
bool test_threads_simple_1();
bool test_mutex_simple_1();
bool test_mutex_trylock_1();
bool test_mutex_when_killed_1();
bool test_threads_max_usage();


int main()
{
	initilize_uthread_in_each_test = false;

	bool ok_so_far = true;
	assert(!initilize_uthread_in_each_test);
	int tmp = uthread_init();
	assert (tmp == UTHREAD_SUCCESS);

	printf("Initializing...\n");
	init_ofer_test_module();
	printf("Starting to run individual tests:\n");
	
	/*RUN_TEST(test_threads_func_uthread_create(),ok_so_far);
	RUN_TEST(test_threads_func_uthread_exit(),ok_so_far);
	RUN_TEST(test_threads_func_uthread_join_1(),ok_so_far);
	RUN_TEST(test_threads_func_uthread_join_2(),ok_so_far);
	RUN_TEST(test_threads_func_uthread_cancel(),ok_so_far);
	RUN_TEST(test_threads_func_uthread_yield(),ok_so_far);
*/
	RUN_TEST(test_mutex_func_uthread_mutex_destroy(),ok_so_far);
	RUN_TEST(test_mutex_func_uthread_mutex_lock(),ok_so_far);
	RUN_TEST(test_mutex_func_uthread_mutex_try_lock(),ok_so_far);
	RUN_TEST(test_mutex_func_uthread_mutex_unlock(),ok_so_far);
/*
	RUN_TEST(test_io_func_uthread_open(),ok_so_far);
	RUN_TEST(test_io_pipes_1(),ok_so_far);

	RUN_TEST(test_threads_simple_1(),ok_so_far);
*/	RUN_TEST(test_mutex_simple_1(),ok_so_far);
	RUN_TEST(test_mutex_when_killed_1(),ok_so_far);
/*	RUN_TEST(test_threads_max_usage(),ok_so_far);
*/
	if (ok_so_far) {
		printf("All tests finished succesfully. Programming level: Chuck Norris :)\n");
	} else {
		printf("IMPORTANT: SOME TEST(S) FAILED!!!\n");
	}

	return 0;
}
